<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      * {
        margin: 0;
        padding: 0;
      }
      .box {
        width: 800px;
        margin: auto;
      }
      header {
        width: 100%;
        height: 40px;
        background-color: #000;
        display: flex;
      }

      p {
        height: 40px;
        width: 100px;
        text-align: center;
        line-height: 40px;
        color: #fff;
      }
      #p1 {
        color: #000;

        background-color: #fff;
      }

      ul {
        width: 100%;
        height: 400px;
        border: 1px red solid;
        display: none;
      }
      li {
        list-style-type: none;
      }
    </style>
  </head>
  <body>
    <div class="box">
      <header>
        <p id="p1">第一节课</p>
        <p id="p2">第二节课</p>
        <p id="p3">第三节课</p>
      </header>
      <footer>
        <ul style="display: block">
          <li>1</li>
          <li>1</li>
          <li>1</li>
        </ul>

        <ul>
          <li>2</li>
          <li>2</li>
          <li>2</li>
          <li>2</li>
          <li>2</li>
        </ul>

        <ul>
          <li>3</li>
          <li>3</li>
          <li>3</li>
          <li>3</li>
          <li>3</li>
        </ul>
      </footer>
    </div>
  </body>
</html>
<script>
  var p = document.getElementsByTagName("p");
  var ul = document.getElementsByTagName("ul");
  for (let i in p) {
    p[i].onmouseover = function () {
        console.log(this);
      ul[i].style.display = "block";
      p[i].style.color = "#000";
      p[i].style.backgroundColor = "#fff";
      
    };
    p[i].onmouseout = function () {
      ul[i].style.display = "none";
      p[i].style.color = "#fff";
      p[i].style.backgroundColor = "#000";
      //   ul[0].style.display='block'
    };
  }  
</script>
